package com.softwaredesign.springboot.mapper;

import com.softwaredesign.springboot.entity.Role;
import com.softwaredesign.springboot.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RoleMapper {

    @Select("select * from sys_role limit #{pageNum}, #{pageSize}")
    List<Role> findAll(Integer pageNum, Integer pageSize);

    @Select("select count(*) from sys_role")
    Integer findAllTotal();

    @Select("select * from sys_role " +
            "where (roleName like #{roleName}) " +
            "limit #{pageNum}, #{pageSize}")
    List<Role> selectPage(Integer pageNum, Integer pageSize, String roleName);

    @Select("select count(*) from sys_role " +
            "where (roleName like #{roleName})")
    Integer selectTotal(String roleName);

    @Update("update sys_role " +
            "set roleName = #{roleName} " +
            "where id = #{id}")
    int update(Role role);
}
